<?php
class News_model extends CI_Model {

    public function __construct()
    {
        $this->load->database();
        $this->load->library('session');
    }
    public function get_news($data)
    {
        $this->db->order_by('id', 'DESC');
        $this->db->limit($data['rows'],($data['page']-1)*10);
        $this->db->like('title',$data['title'],'both');
        $this->db->like('weid',$data['weid'],'both');
        $this->db->like('us_id',$data['us_id'],'both');
        $query = $this->db->get('ims_enread_material');

        return $query->result_array();
    }
    public function total_news(){
        $query = $this->db->get('ims_enread_material');
        return $num = $query->num_rows();
    }
    public function get_new($id) {
        $this->db->where('id',$id);
        $query = $this->db->get('ims_enread_material');
        return $query->result_array();
    }
    public function delete_new($id)
    {
        $this->db->where('id',$id);
        $this->db->delete('ims_enread_material');
    }
    public function save_news($data)
    {

        if($this->db->where('id',$data['id'])){
            $this->db->replace('ims_enread_material',$data);
        }else{
            $this->db->insert('ims_enread_material', $data);
        }
    }
    public function ims_account_wechats($name){
       // var_dump($name);
        if($name=="4"){
            $this->db->where('level',"4");
        }else{
            $this->db->where('level!=', "4");
        }
        
        $query = $this->db->get('ims_account_wechats');
        return $query->result_array();
    }
    public function ims_account_wechats2($id){
        $this->db->where('uniacid',$id);
        $query = $this->db->get('ims_account_wechats');
        //var_dump($query->result_array());
        return $query->row_array();
    }
}